/**
 * Service con metodi di utilita' per formattazione Data
 */
BootApplication
.service("DateService",['configuration'
                       ,'$translate'
                       ,"$filter"
                       ,"$rootScope"
                , function(configuration
                		  ,$translate
                		  ,$filter
                		  ,$rootScope
) {
    /**
     * Format date in string
     * @param _date: date object 
     * @param _keyFormat: _key dei message relativo al formato
     * @return string della data formattata 
     */
	this.formatDateTimeByMessage = function(_date, _keyFormat){
		return $filter('date')(_date, $translate.instant(_keyFormat));
	};
	/**
	 * Format date in string
	 * @param _date: date object 
     * @param _format: formato
     * @return string della data formattata
	 */
	this.formatDateTime = function(_date, _format){
		return $filter('date')(_date, _format);
	};
	/**
	 * Format utc time in string
	 * @param _utc: utc timestamp 
	 * @param _keyFormat: _key dei message relativo al formato
	 * @return string della data formattata 
	 */
	this.formatUtcByMessage = function(_utc, _keyFormat){
		return this.formatDateTimeByMessage(new Date(_utc), _keyFormat);
	};
	/**
	 * Format utc time in string
	 * @param _utc: utc timestamp 
	 * @param _format: formato
	 * @return string della data formattata
	 */
	this.formatUtc = function(_utc, _format){
		return this.formatDateTime(new Date(_utc), _format);
	};

	/**
	 * formato data per datetimepicker
	 */
	this.dateTimePickerFormat = function(){
		if($rootScope.language == 'it')
			return "dd/MM/yyyy HH:mm";
		else
			return "yyyy-MM-dd HH:mm";
	};
	/**
	 * formato data per datepicker
	 */
	this.datePickerFormat = function(){
		if($rootScope.language == 'it')
			return "dd/MM/yyyy";
		else
			return "yyyy-MM-dd";
	};
}]);